/******************************************************
 file : JavaScript
 author : BrighTan
 organization : Digital Media Technology Institute
 function : Touchmove and drag to fresh data,and control the animation.
 *******************************************************/

var oldFinger = {};
var targetSlider = $(".content-slide");
targetSlider.bind("touchmove",
    function () {
        var scrollTop = $(this)[0].scrollTop;
        var scrollHeight = $(this)[0].scrollHeight;
        var clientHeight = $(this).height();
        if (scrollHeight <= clientHeight + scrollTop) {
            var finger = event.changedTouches[0];
            var oldTop = parseInt($(this).css("top")) + (finger.pageY - oldFinger.top)/2;
            var oldTopStr = oldTop + "px";
            $(this).css("top", oldTopStr);
            oldFinger.top = finger.pageY;
            /*            if(flag==1) {
                document.getElementById('flag').value=0;*/
        }
    });
targetSlider.bind("touchend", function () {
    if ($(this).css("top") !== "0px") {
        /*   targetSlider.css("transition", "top .5s");*/
        $(this).children().eq(2).children().show();
        /*            if (isTopOver === true)
                        freshData($(this));*/
        var scrollTop = $(this)[0].scrollTop;
        var scrollHeight = $(this)[0].scrollHeight;
        var clientHeight = $(this).height();
        if (scrollHeight <= clientHeight + scrollTop && parseInt($(this).css("top")) < -80) {
            var xiabiao = $(this).index();
            moreData($(this),xiabiao+1);
            var loading = $(this).children(".load-container").children();
            loading.children("p").text("正在加载");
            loading.children("span").toggleClass("load-active", true);
        }
        $(this).css("top", "0px");
        oldFinger = {};
        /*targetSlider.css("transition", "none");*/
    }
});
